package net.aetherial.context.grounding.estimators;

import java.util.*;

import net.aetherial.context.grounding.annotators.*;

/**
 * Abstract class that describes the interface of an estimator. An estimator takes a unit of conversation and returns a numeric estimate 
 * describing a property of that turn. The actual numeric estimates are determined by the individual estimators. (In this case, estimators
 * generate estimates of grounding activity.)
 */

public abstract class Estimator 
{
	public static String SENDER_KEY = "Sender";
	public static String CONTRIBUTION_KEY = "Contribution";
	public static String SCORE_KEY = "Score";
	
	/**
	 * Returns an estimate of a given conversational unit.
	 * 
	 * @param sender			Sender/speaker.
	 * @param contribution		Contents of the conversational unit.
	 * @param score				Optional coded score.
	 * @return					Numeric estimate of a property of the conversational unit.
	 */
	
	public abstract double estimate (String sender, String contribution, double score);
	
	/**
	 * Returns the name of the estimator. This is used to label the estimator's predictions in an <code>AggregateEstimator</code>.
	 * 
	 * @return
	 */
	
	public abstract String getName ();
	
	/**
	 * Selects a specific annotated layer for analysis. By default this selects the original conversational unit, but subclasses may override this to
	 * use specific annotated layers instead.
	 * 
	 * @param layers		Collection of annotated layers.
	 * @return				Numeric estimate of a property of the selected conversational unit layer.
	 */

	public double estimate (Map<String, Map<String, Object>> layers)
	{
		Map<String, Object> layer = layers.get (Annotator.DEFAULT_LAYER);
		
		String sender = (String) layer.get (SENDER_KEY);
		String contribution = (String) layer.get (CONTRIBUTION_KEY);
		Double score = (Double) layer.get (SCORE_KEY);

		return this.estimate (sender, contribution, score);
	}
	
	/**
	 * Resets the estimator for processing a new conversation.
	 */
	
	public void reset ()
	{

	}
}
